﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.SqlClient;

namespace Securfid
{
    class Lectures
    {
        //Variables de la classe Lectures
        private int id_cegep;
        private string id_rfid;
        private string emplacement;
        private string time;
        private string heure_alarme;
        private bool alarme;

        //Intialisation
        public void Initialise(int C, string R, string E, string T, string HA, bool A)
        {
            this.id_cegep = C;
            this.id_rfid = R;
            this.emplacement = E;
            this.time = T;
            this.heure_alarme = HA;
            this.alarme = A;
        }

        //Accesseurs
        public int Getid_cegep()
        {
            return id_cegep;
        }
        public String Getid_rfid()
        {
            return id_rfid;
        }
        public String Getemplacement()
        {
            return emplacement;
        }
        public String Gettime()
        {
            return time;
        }
        public String GetHeureAlarme()
        {
            return heure_alarme;
        }
        public bool GetAlarme()
        {
            return alarme;
        }

        public static List<Lectures> Alarme(List<Lectures> TagSQL, int temps_alarme, DateTime heureactuelle)
        {
            List<Lectures> alarme = new List<Lectures>();

            foreach (Lectures tag in TagSQL)
            {
                DateTime tagtime = Convert.ToDateTime(tag.Gettime());
                System.TimeSpan timediff = heureactuelle - tagtime;

                if (timediff.TotalSeconds > temps_alarme)
                {
                    alarme.Add(tag);
                    Console.WriteLine("Alarme sur le tag : {0}", tag.Getid_rfid());
                }
            }
            return alarme;
        }
    }

    class Configs
    {
        //Variables de la classe Lectures
        private int temps_lectures;
        private int temps_alarme;

        //Intialisation
        public void Initialise(int L, int A)
        {
            this.temps_lectures = L;
            this.temps_alarme = A;
        }

        //Accesseurs
        public int Gettemps_lectures()
        {
            return temps_lectures;
        }
        public int Gettemps_alarme()
        {
            return temps_alarme;
        }
    }
}